/* 
    用于统一管理项目中所有的ajax请求 
*/

// 引入二次封装后的 ajax
import ajax from './ajax'
import mAjax from './mAjax'

// 搜索：获取默认关键字和热门关键字
export const reqDefaultHotKeyword = () => ajax.get('/xhr/search/init.json')
// 获取值得买轮播的数据
export const reqWorthBannerData = () => ajax.get('/topic/v1/know/navWap.json')
//获取瀑布流的分页数据
export const reqWorthWaterfallData = (page, size) => ajax.get(`/topic/v1/find/recAuto.json?page=${page}&$size=${size}`)
// 搜索：实时关键字列表
export const reqAllKeywordInfo1 = (keyword) =>ajax.get(`/xhr/search/search.json?__timestamp=1630133434953&needPopWindow=true&searchWordSource=7&stillSearch=false&_stat_search=autoComplete&itemId=0&size=40&upperPrice=-1&floorPrice=-1&matchType=0&categoryId=0&descSorted=false&sortType=0&keyword=${keyword}`)
// 分类：获取分类首页左侧列表数据
export const reqceshi = (categoryId) => ajax.get(`/item/cateList.json?__timestamp=1630131286110&categoryId=${categoryId}`)
// 分类：获取分类首页右侧内容数据
export const reqCategorycontent =(categoryId) => ajax.get(`/item/cateList.json?__timestamp=1630131455012&categoryId=${categoryId}`)
// 分类：获取分类内容商品页面数据
export const reqCategoryList =(categoryId,subCategoryId) => ajax.get(`/item/list.json?__timestamp=1630133942864&categoryType=0&subCategoryId=${subCategoryId}&categoryId=${categoryId}`)


export const reqKeywordsList = (keyword) => ajax.post('/xhr/search/searchAutoComplete.json', `keywordPrefix=${keyword}`, { headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" } })
// 搜索：获取所有关键字相关商品列表信息

export const reqAllKeywordInfo = ({searchTitle,categoryId=0,descSorted=false,sortType=0,floorPrice=-1,upperPrice=-1}) =>ajax.get(`/xhr/search/search.json?__timestamp=1630133434953&needPopWindow=true&searchWordSource=7&stillSearch=false&_stat_search=autoComplete&itemId=0&size=40&upperPrice=${upperPrice}&floorPrice=${floorPrice}&matchType=0&categoryId=${categoryId}&descSorted=${descSorted}&sortType=${sortType}&keyword=${searchTitle}`)
//购物车:获取购物车数据
export const reqShopList = () => mAjax.get('/cart/cartList')
//登录
export const reqLogin = (params) => mAjax.post('/user/passport/login',params)
//首页：获取首页数据
export const reqIndexData = () => ajax.get('/xhr/index.json?__timestamp=1644811072709')
//首页：获取首页下分类页面数据
export const reqIndexCategoryData = (categoryId) => ajax.get(`/item/list.json?__timestamp=1644815431482&categoryId=${categoryId}`)

//获取购物车数据
export const shopList=()=>mAjax.get('/cart/cartList')
//获取购物车单选 购物车单选按钮
export const reqCheckSkuInCart = (skuId,isChecked) => mAjax.get(`/cart/checkCart/${skuId}/${isChecked}`)

//用于获取商品详情
export const reqDetailInfo = (id) => mAjax.get(`/item/${id}`)
//添加到购物车
export const reqAddCart = (skuId,skuNum) => mAjax.post(`/cart/addToCart/${skuId}/${skuNum}`)

